package com.yanxi.mapper;

import com.yanxi.pojo.Student;
import com.yanxi.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    //分页查询班级学员
    //@Select("select * from student where name like concat('%',#{name},'%') and gender = #{gender}")
    List<Student> pageStudent(StudentQueryParam studentQueryParam);


    //新增学员
    @Select("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time) values(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void saveStudent(Student student);


    //根据id查询学员
    @Select("select * from student where id = #{id}")
    Student findById(Integer id);

    //修改学员
    void update(Student student);

    //删除学员
    void delete(List<Integer> ids);

    //扣分
    @Update("update student set violation_score =violation_score + #{score},violation_count=violation_count+1,update_time= localtime where id = #{id}")
    void violation(Integer id, Short score);

    //统计班级人数
    List<Map<String, Object>> CountStudentCountData();


    //统计学生学历人数
    List<Map<String, Object>> CountStudentDegreeData();
}
